package com.cysyz.json.filter;

import com.alibaba.fastjson.JSON;
import com.cysyz.json.fastjson.ComplexPropertyPreFilter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class A {
       
    private Integer aid;
       
    private B b;
       
    private List<C> c = new ArrayList<>();
       
    public A() {
        super();
    }
       
    public static void main(String[] args) {
        A a = new A();
        a.setAid(1);

        B b = new B();
        b.setBid(2);

        a.setB(b);
        b.setA(a);

        C c = new C();
        c.setId(3);

        a.getC().add(c);
        b.getC().add(c);
        c.setA(a);
        c.setB(b);

        ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();

        filter.setExcludes(new HashMap<Class<?>, String[]>() {

            private static final long serialVersionUID = -8411128674046835592L;

            {
                put(A.class, new String[]{"aid"});
                put(B.class, new String[]{"bid", "a"});
                put(C.class, new String[]{"a", "b"});
            }
        });

        System.out.println(JSON.toJSONString(a, filter));

    }
       
    public Integer getAid() {
        return aid;
    }
       
    public void setAid(Integer aid) {
        this.aid = aid;
    }  public B getB() {
        return b;
    }
       
    public void setB(B b) {
        this.b = b;
    }
       
    public List<C> getC() {
        return c;
    }
       
    public void setC(List<C> c) {
        this.c = c;
    }
       
}